import request from '@/utils/request'

export default {
    //获取合同列表
    getContractList(searchModel) {
        return request({
            url: '/contract',
            method: 'get',
            params: {
                page: searchModel.pageNo,
                paginate: searchModel.pageSize,
                pageSize: searchModel.pageSize,
                uid: searchModel.uid,
                clientID: searchModel.clientID,
                type1: searchModel.type1,
                keyword: searchModel.keyword,
            }
        });
    },

    //获取合同类型
    getTypeList(type) {
        return request({
            url: '/contractType',
            method: 'get',
            params: {
                type: type,
            }
        });
    },

    //添加/修改合同
    clientFrom(form) {
        if (form.id) {
            return request({
                url: '/contract/' + form.id,
                method: 'post',
                params: {
                    //合同标题
                    title: form.title,
                    //客户id
                    client_id: form.client_id,
                    //主类型
                    type1: form.type1,
                    //细分类型
                    type2: form.type2,
                },
            });
        } else {
            return request({
                url: '/contract',
                method: 'post',
                params: {
                    //合同标题
                    title: form.title,
                    //客户id
                    client_id: form.client_id,
                    //主类型
                    type1: form.type1,
                    //细分类型
                    type2: form.type2,
                    //合同金额
                    money: form.money,
                    //时间
                    time: form.time,
                    //年份
                    year: form.year,
                    //联系人
                    linkman: form.linkman,
                    //联系电话
                    phone: form.phone,
                    //文档链接
                    document_link: form.document_link,
                    //收费节点列表
                    tableData: form.tableData,
                },
            });
        }

    },

    //根据id获取合同详情
    getInfo(id) {
        return request({
            url: '/contract/' + id,
            method: 'get',
        });
    },

    //添加修改年份合同  
    saveContractYear(form) {
        if (form.id) {
            var url = '/contract_year/' + form.id;
        } else {
            var url = '/contract_year';
        }

        return request({
            url: url,
            method: 'post',
            params: {
                //主合同id
                contract_id: form.contract_id,
                //id
                id: form.id,
                //年份
                year: form.year,
                //开始时间
                start_at: form.start_at,
                //结束时间
                end_at: form.end_at,
                //合同金额
                money: form.money,
                //时间
                time: form.time,
                //联系人
                linkman: form.linkman,
                //联系电话
                phone: form.phone,
                //文档链接
                document_link: form.document_link,
                //收费节点列表
                tableData: form.tableData,
            },
        });

    },

    //根据id获取年份合同内容
    getContractById(id) {
        return request({
            url: '/contract_year/' + id,
            method: 'get',
        });
    },

    //删除年份合同
    delContractById(id) {
        return request({
            url: '/contract_year/delete/' + id,
            method: 'post',
        });
    },

    //模糊搜索年份合同名称
    contractKeyword(keyword) {
        return request({
            url: '/contract_year_keyword/' + keyword,
            method: 'get',

        });
    },

    //根据id获取项目绩效信息
    getContractJixiao(id){
        return request({
            url: '/contract_year_jixiao/' + id,
            method: 'post',
        });
    },

    //获取合同文件列表
    getContractFileList(id){
        return request({
            url: '/contract_file/' + id,
            method: 'get',
        });
    },

    //收款记录详情
    getContractPayInfo(id){
        return request({
            url: '/contract_pay_info/' + id,
            method: 'get',
        });
    },

    //添加/修改收款记录
    saveContractPay(form) {
        return request({
            url: '/contract_pay',
            method: 'post',
            params: {
                id: form.id,
                practical_money: form.practical_money,
                practical_money_time: form.practical_money_time,
                invoice_type: form.invoice_type,
                invoice_tax_rate: form.invoice_tax_rate,
                invoice_money: form.invoice_money,
            },
        });

    },

    // getClientList(searchModel) {
    //     return request({
    //         url: '/client',
    //         method: 'get',
    //         params:{
    //             page:searchModel.pageNo,
    //             paginate:searchModel.pageSize,
    //             pageSize:searchModel.pageSize,
    //             username:searchModel.username,
    //             uid:searchModel.uid,
    //         }
    //     });
    // },


}